using System;
using System.Windows;
namespace Microsoft.Phone.Controls.Primitives
{
	public class PanningBackgroundLayer : PanningLayer
	{
		protected override double PanRate
		{
			get
			{
				double result = 1.0;
				if (base.Owner != null && base.ContentPresenter != null)
				{
					result = (Math.Max((double)base.Owner.ViewportWidth, base.ContentPresenter.get_ActualWidth()) - (double)(base.Owner.ViewportWidth / 5 * 4)) / (double)Math.Max(base.Owner.ViewportWidth, base.Owner.ItemsWidth);
				}
				return result;
			}
		}
		protected override void UpdateWrappingRectangles()
		{
			PerfLog.BeginLogMarker(PerfMarkerEvents.MPC_PANO_UPDATEWRAPPING, "Background Panning Layer");
			UIElement arg_2F_0 = base.LeftWraparound;
			Visibility visibility;
			base.RightWraparound.set_Visibility(visibility = (base.IsStatic ? 1 : 0));
			arg_2F_0.set_Visibility(visibility);
			if (!base.IsStatic && base.Owner.get_Background() != null)
			{
				FrameworkElement arg_6E_0 = base.RightWraparound;
				double actualHeight;
				base.LeftWraparound.set_Height(actualHeight = base.ContentPresenter.get_ActualHeight());
				arg_6E_0.set_Height(actualHeight);
				FrameworkElement arg_93_0 = base.RightWraparound;
				double width;
				base.LeftWraparound.set_Width(width = (double)base.Owner.ViewportWidth);
				arg_93_0.set_Width(width);
				FrameworkElement arg_B9_0 = base.LeftWraparound;
				Thickness margin;
				base.RightWraparound.set_Margin(margin = base.ContentPresenter.get_Margin());
				arg_B9_0.set_Margin(margin);
				base.RightWraparound.set_Fill(base.Owner.get_Background());
				base.LeftWraparound.set_Fill(base.Owner.get_Background());
			}
			if (base.LocalTransform != null)
			{
				double num = (base.LeftWraparound.get_Visibility() == null) ? (-base.LeftWraparound.get_Width() - base.LeftWraparound.get_Margin().get_Left()) : 0.0;
				base.LocalTransform.set_X(base.IsStatic ? 0.0 : (num - base.LeftWraparound.get_Margin().get_Right()));
			}
			PerfLog.EndLogMarker(PerfMarkerEvents.MPC_PANO_UPDATEWRAPPING, "Background Panning Layer");
		}
	}
}
